//
//  HTStautsToolBar.swift
//  weibo
//
//  Created by JonsonLiu on 16/4/21.
//  Copyright © 2016年 liujonson. All rights reserved.
//

import UIKit

class HTStautsToolBar: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUI(){
    
        let rightButton = addChildButton("转发", imaged: "timeline_icon_retweet")
        let commenButton = addChildButton("评论", imaged: "timeline_icon_comment")
        let leftButton = addChildButton("👍", imaged: "")//timeline_icon_unlike
        let sp1 = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        let sp2 = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        addSubview(sp1)
        addSubview(sp2)
        rightButton.snp_makeConstraints { (make) -> Void in
            make.leading.top.bottom.equalTo(self)
            make.width.equalTo(commenButton)
        }
        
        commenButton.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(rightButton.snp_trailing)
            make.top.bottom.equalTo(self)
            make.width.equalTo(leftButton)
        }
        
        leftButton.snp_makeConstraints { (make) -> Void in
            make.trailing.top.bottom.equalTo(self)
            make.leading.equalTo(commenButton.snp_trailing)
            make.width.equalTo(rightButton)
        }
        
        
        sp1.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(rightButton.snp_trailing)
            make.centerY.equalTo(self)
        }

        sp2.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(commenButton.snp_trailing)
            make.centerY.equalTo(self)
        }
        
        
    }
    
   
    
    func addChildButton(stringName : String , imaged : String) -> UIButton{
    
        let button = UIButton()
        button.setTitle(stringName, forState: .Normal)
        button.setImage(UIImage(named: imaged), forState: .Normal)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background_highlighted"), forState: .Highlighted)
        button.setBackgroundImage(UIImage(named: "timeline_card_bottom_background"), forState:.Normal )
        addSubview(button)

        return button
    }

}
